%h1.page_title Edit user details
%table.user_edit
  - form_for @user, :method => :update do |form| 
    %tr
      %td.field_title First Name:
      %td.field= form.text_field :first_name
      %td.error= error_message_on :user, :first_name
    %tr
      %td.field_title Last Name:
      %td.field= form.text_field :last_name
      %td.error= error_message_on :user, :last_name
    %tr
      %td.field_title E-mail:
      %td.field
        = form.text_field :email
        *
      %td.error= error_message_on :user, :email
    %tr
      %td.field_title Street Address:
      %td.field= form.text_field :street_address
      %td.error= error_message_on :user, :street_address
    %tr
      %td.field_title City:
      %td.field= form.text_field :city
      %td.error= error_message_on :user, :city
    %tr
      %td.field_title State:
      %td.field= form.text_field :state
      %td.error= error_message_on :user, :state
    %tr
      %td.field_title Zip Code:
      %td.field= form.text_field :zip
      %td.error= error_message_on :user, :zip
    %tr
      %td.field_title Phone Number:
      %td.field= form.text_field :phone_number
      %td.error= error_message_on :user, :phone_number
    %tr
      %td.field_title Password:
      %td.field= form.password_field :password
      %td.error= error_message_on :user, :password
    %tr
      %td.field_title Confirm Password:
      %td.field= form.password_field :password_confirmation
      %td.error= error_message_on :user, :password_confirmation
    - if logged_in? && current_user.is_admin?
      %tr
        %td.field_title Admin?:
        %td
          %select{:name => "user[is_admin]"}
            %option{:value => "1", :selected => ('selected' if @user.is_admin?)} Yes
            %option{:value => "0", :selected => ('selected' if !@user.is_admin?)} no
        %td= error_message_on :user, :is_admin
      %tr
        %td.field_title Client?:
        %td.field
          %select{:name => "user[is_client]"}
            %option{:value => "0", :selected => ('selected' if @user.is_client?)} No
            %option{:value => "1", :selected => ('selected' if @user.is_client?)} Yes
        %td.error= error_message_on :user, :is_client
      %tr
        %td.field_title Galleries:
        %td.field
          - if @galleries.empty?
            No galleries have been created yet.
            %a{:href => new_gallery_url, :title => "Create a new Gallery"}Create one
          - else
            %select{:id => "user[gallery_ids][]", :name => "user[gallery_ids][]", :multiple => true, :size => 8, :width => 10}
              - @galleries.each do |gallery|
                %option{:value => gallery.id, :selected => ("selected" if @user.galleries.include?(gallery))}= gallery.name
    %tr
      %td
      %td.submit= submit_tag 'Update'
%div.galleries
  %h2.page_title Your Galleries
  = render :partial => "galleries"
%div.user_comments
  - unless @user.comments.empty?
    %h2.comments= "#{@user.login}'s comments"
  - @user.comments.each do |comment|
    %div.comment_container
      %div.creation_information
        %div.user_login
          %a{:href => user_url(comment.user)}= comment.user.login
        %div.comment_time
          = comment.created_at.strftime("%m/%d/%y at %I:%M %p")
        - if logged_in? && current_user.is_admin?
          %div.delete_comment
            - form_for comment, :html => {:method => :delete} do |form|
              = submit_tag "delete"
      %div.user_comment
        = comment.text
        - if comment.for_photo?
          %div.comment_photo
            %a{:href => photo_url(comment.photo)}
              %img.photo_thumb{:src => comment.photo.public_filename(:thumb)}
        - if comment.for_video?
          %div.comment_video
            %a{:href => video_url(comment.video)}
              %img.video_thumb{:src => comment.video.thumbnail}
    %div.clear_fix